// use localStorage to store the authority info, which might be sent from server in actual project.
export function getAuthority(str) {

  const userInfo = JSON.parse(localStorage.getItem('userinfo'))
  if(userInfo == undefined){
    return   ['guest'];
  }

  if(userInfo.tel == '18251846048'){
    return   ['admin'];
  }else {
    return   ['user'];
  }
}

export function setAuthority(authority) {
  const proAuthority = typeof authority === 'string' ? [authority] : authority;
  return localStorage.setItem('antd-pro-authority', JSON.stringify(proAuthority));
}

/**
 * 在本地存储key-value
 * @param key
 * @param value
 */
export function  setValueWithLocalStorage(key,value) {
  const insert = typeof value === 'string' ? value : JSON.stringify(value);
  return localStorage.setItem(key, insert);
}

/**
 * 从本地LocalStorage查询数据
 * @param key
 * @returns {string | null}
 */
export function getValueWithLocalStorage(key) {
  const  ret =  localStorage.getItem(key)
  return JSON.parse(ret)
}


export const getOwner = () => {
  const userInfo = getValueWithLocalStorage('userinfo') || {}
  return userInfo.tel;
}